<?php
namespace app\index\controller;

use think\Config;
use think\Controller;
use think\Request;

class Article extends Base
{
    protected $technology = [3,4,5,6];
    protected $honors = [7];
    protected $product = [2];
    protected $news = [1];

	// 技术中心页面
	public function technology(Request $request)
	{
	    $action = $request->param('id','0');
        $action = $action ? $action : $this->technology;
        $info = \ArticleHelper::getArticle($action);
        if (empty($info)){
	        return redirect('/');
        }
        $page = $info->render();
        $this->assign('action',is_numeric($action)?$action:0);
        $this->assign('info',$info);
        $this->assign('page',$page);
    	return $this->fetch('article/technology');
	}
	// 技术中心页面
	public function technology_detail(Request $request)
	{
	    $id = $request->param('id','0');
        $info = \ArticleHelper::getArticleInfo($id);
        if (empty($info)){
	        return redirect('/technology.html');
        }
        $this->assign('info',$info);
        $this->assign('action',$info['cate_id']);
    	return $this->fetch('article/technology_detail');
	}
	//资质荣誉集团荣誉
    public function honors(){
        $info = \ArticleHelper::getArticle($this->honors,8);
        if (empty($info)){
            return redirect('/');
        }
        $page = $info->render();
        $this->assign('info',$info);
        $this->assign('page',$page);
        return $this->fetch('article/honors');
    }
    //资质荣誉集团荣誉
    public function honor(Request $request){
        $id = $request->param('id','0');
        $info = \ArticleHelper::getArticleInfo($id);
        if (empty($info)){
            return redirect('/technology.html');
        }
        $this->assign('info',$info);
        $this->assign('action',$info['cate_id']);
        return $this->fetch('article/honor_detail');
    }

    public function product($id = 0){
        if (empty($id)){
            $info = \ArticleHelper::getArticle($this->product,8);
            $this->assign('info',$info);
            return $this->fetch('article/product');
        }else{
            $info = \ArticleHelper::getArticleInfo($id,$this->product);
            if (!empty($info)){
                $this->assign('info',$info);
                return $this->fetch('article/product_detail');
            }else{
                return redirect('/');
            }
        }

    }
    public function news($id = 0){
        if (empty($id)){
            $info = \ArticleHelper::getArticle($this->news,8);
            $this->assign('info',$info);
            return $this->fetch('article/news');
        }else{
            $info = \ArticleHelper::getArticleInfo($id,$this->news);
            if (!empty($info)){
                $this->assign('info',$info);
                return $this->fetch('article/news_detail');
            }else{
                return redirect('/');
            }
        }

    }

}
